package com.boot.project.controller;

import com.boot.project.domain.CouponCardDO;
import com.boot.project.domain.OrderDo;
import com.boot.project.service.InfoService;
import com.boot.project.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/****************************************************
 *
 *  订单
 *
 * @author hw
 * @version 1.0
 **************************************************/
@RequestMapping("/order")
@RestController
public class OrderController {
    @Autowired
    private OrderService orderService;

    @PostMapping("/add")
    public int save(@RequestBody OrderDo orderDo){
        return orderService.add(orderDo);
    }

    @GetMapping("/list")
    public Map<String, Object> list(@RequestParam Integer pageNum, Integer pageSize){
        return orderService.list(pageNum, pageSize);
    }

    @GetMapping("/listBy")
    public Map<String, Object> listBy(@RequestParam String openId , Integer pageNum, Integer pageSize){
        return orderService.listBy(openId, pageNum, pageSize);
    }

    @PostMapping("/listByopenId")
    public List<OrderDo> listByopenId(@RequestBody OrderDo orderDo){
        return orderService.listByopenId(orderDo);
    }

    // 未付款订单
    @GetMapping("/unpaid")
    public List<OrderDo> unpaid(@RequestParam String openId){
        return orderService.unpaid(openId);
    }

    // 已付款订单
    @GetMapping("/paid")
    public List<OrderDo> paid(@RequestParam String openId){
        return orderService.paid(openId);
    }

    // 获取预定记录
    @GetMapping("/orderRecord")
    public List<Map<String, Object>> orderRecord(@RequestParam String openId){
        return orderService.orderRecord(openId);
    }

    // 修改订单状态接口
    @PutMapping("/changeOrderStatus")
    public Map<String, Object> changeOrderStatus(@RequestParam String openId){
        return orderService.changeOrderStatus(openId);
    }
}